#!/bin/sh

set +e

SPARSEOPTS=
JIT_OPT=

DIRNAME=`dirname $0`
LLI=`"${LLVM_CONFIG:-llvm-config}" --bindir`/lli

if [ $# -eq 0 ]; then
  echo "`basename $0`: no input files"
  exit 1
fi

while [ $# -gt 0 ]; do
	case $1 in
	--jit)
		JIT_OPT=
		;;
	--no-jit)
		JIT_OPT="-force-interpreter"
		;;
	*)
		SPARSEOPTS="$SPARSEOPTS $1 "
		;;
	esac
	shift
done

$DIRNAME/sparse-llvm ${SPARSEOPTS} | $LLI ${JIT_OPT}
